<!--  -->
<template>
  <div class="container">
    <Header title="社会组织评估申报平台" :back="true"></Header>
    <div class="page_content">
      <div>
        <a-row>
          <a-col :span="6" class="info_container">
            <div class="about">关于我</div>
            <div class="info">
              <div>{{ user.userName }}</div>
              <div>申请人</div>
            </div>
          </a-col>
          <a-col :span="17" style="background: #fff" class="info_container">
            <a-tabs
              default-active-key="1"
              @change="handleChange"
              :animated="false"
              style="margin-bottom: 15px"
            >
              <a-tab-pane key="1" tab="历史记录">
                <a-select
                  v-model="declarationSystemId"
                  style="width: 200px"
                  placeholder="请选择申报体系"
                  @change="changeSystem"
                  allowClear
                >
                  <a-select-option value="">请选择</a-select-option>
                  <a-select-option
                    v-for="item in declarationSystemIdList"
                    :key="item.id"
                    :value="item.name"
                    >{{ item.name }}</a-select-option
                  >
                </a-select>
                <div v-for="(item, index) in list" :key="index" class="history">
                  <div class="item_container">
                    <div class="item" style="padding: 15px 0">
                      {{ item.name }}
                    </div>
                    <div class="item">
                      <div>申请类别</div>
                      <div>{{ item.socialOrganizationType }}</div>
                    </div>
                    <div class="item">
                      <div>申请级别</div>
                      <div>{{ item.level }}</div>
                    </div>
                    <div
                      class="item"
                      v-if="item.status == 4 || item.status == 5"
                    >
                      <img src="@/assets/wtg.png" class="statusImg" v-if="Number(item.recordScoreSum)<Number(item.levelPassMark)" />
                      <img src="@/assets/ytg.png" v-else-if="Number(item.recordScoreSum)>=Number(item.levelPassMark)" class="statusImg" />
                    </div>
                    <!-- <div class="item">
                    <div>专家打分</div>
                    <div>{{ item.score }}</div>
                  </div>
                  <div class="item time">
                    <div>创建时间</div>
                    <div>{{ item.createTime }}</div>
                  </div> -->
                  </div>
                  <div class="item detail">
                    <a-button
                      v-if="item.declarationInfoStatus == 3"
                      @click="toDetail(item)"
                      type="primary"
                      >查看详情</a-button
                    >
                  </div>
                </div>
              </a-tab-pane>
              <!-- <a-tab-pane key="2" tab="账户">
                <a-form :form="form" ref="form">
                  <a-form-item label="新密码">
                    <a-input-password
                      allowClear
                      v-decorator="[
                        'password',
                        { rules: [{ validator: validatePassword }] },
                      ]"
                    ></a-input-password>
                  </a-form-item>
                  <a-form-item label="确认密码">
                    <a-input-password
                      allowClear
                      v-decorator="[
                        'password1',
                        {
                          rules: [
                            {
                              validator: validateToNextPassword,
                            },
                          ],
                        },
                      ]"
                    ></a-input-password>
                  </a-form-item>
                </a-form>
                <a-button type="primary" @click="handleUpdate">更新</a-button>
              </a-tab-pane> -->
              <a-tab-pane key="3" tab="数智">
                <div class="yiyan">
                  <div class="yiyan_img">
                    <img src="@/assets/update.png" alt="" />
                  </div>
                  <div class="yiyan_text">正在努力开发中</div>
                </div>
              </a-tab-pane>
            </a-tabs>
          </a-col>
        </a-row>
      </div>
    </div>
  </div>
</template>

<script>
import Header from "@/components/header";
import { getMyDeclareList, getDeclarationSystemList } from "@/api/profile";
import { socialOrganizationTypeList } from "@/api";
export default {
  data() {
    this.formLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 3 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 },
      },
    };
    return {
      user: {},
      list: [
        { name: "社会团体", type: "社会团体", id: 1 },
        { name: "社会团体", type: "社会团体", id: 2 },
        { name: "社会团体", type: "社会团体", id: 3 },
      ],
      form: this.$form.createForm(this),
      typeList: [],
      declarationSystemIdList: [],
      declarationSystemId: "",
    };
  },
  created() {
    this.user = this.$storejs.get("userInfo").user;
    this.getMyDeclareList();
    this.getTypeList();
    this.getDeclarationSystemList();
  },
  methods: {
    //获取体系列表
    getDeclarationSystemList() {
      getDeclarationSystemList({
        size: 9999,
        current: 1,
        progressStatus: "",
      }).then((res) => {
        console.log(res);
        this.declarationSystemIdList = res.data.records;
      });
    },
    // 获取组织类别列表
    getTypeList() {
      socialOrganizationTypeList({}).then((res) => {
        this.typeList = res.data;
      });
    },
    getMyDeclareList() {
      getMyDeclareList({
        size: 9999,
        current: 1,
        name: this.declarationSystemId,
      }).then((res) => {
        console.log("res==", res);
        this.list = res.data.records;
      });
    },
    // 校验密码是否为空
    validatePassword(rule, value, callback) {
      if (!value) {
        callback(new Error("请输入密码"));
      } else {
        callback();
      }
    },
    // 校验确认密码
    validateToNextPassword(rule, value, callback) {
      if (!value) {
        callback(new Error("请再次输入密码"));
      } else if (value && value !== this.form.getFieldValue("password")) {
        callback(new Error("两次输入的密码不一致"));
      } else {
        callback();
      }
    },
    // 切换tab
    handleChange(key) {
      console.log(key);
    },
    // 查看历史记录详情
    toDetail(data) {
      // console.log(this.typeList);
      this.$storejs.set("enterInfo", {
        declarationSystemId: data.id,
        declarationInfoId: data.declarationInfoId,
        userId: data.userId,
        socialOrganizationTypeId: data.socialOrganizationId,
      });
      this.$storejs.set("declarationSystem", data);
      console.log(this.$storejs.get("declarationSystem"));
      // this.$router.push({
      //   path: "/apply",
      //   query: {
      //     showBtn: false,
      //   },
      // });
      this.$router.push({
        path: "/apply",
        // query: {
        //   showBtn: false,
        // },
      });
    },
    // 修改密码
    handleUpdate() {
      this.form.validateFields((errors, values) => {
        if (!errors) {
          console.log(values);
        } else {
          console.log("error");
        }
        // ...
      });
    },
    changeSystem(val) {
      this.getMyDeclareList();
    },
  },
  components: { Header },
};
</script>
<style lang="less" scoped>
.container {
  background: #f1f2f3;
  font-size: 14px;
  color: #303133;
  .page_content {
    // width: 1400px;
    margin: 0 auto;
    padding: 20px;

    height: calc(100vh - 64px);
    .about {
      padding: 18px 20px;
      border-bottom: 1px solid #ebeef5;
      box-sizing: border-box;
    }
    .info {
      padding: 50px 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      div:first-child {
        font-weight: bold;
      }
      div:nth-child(2) {
        margin-top: 10px;
        color: #777;
      }
    }
  }
}
.info_container {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  background: #fff;
  .history:nth-child(n + 3) {
    margin-top: 15px;
  }
  .history {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #eee;
    padding: 30px 20px;
    border-radius: 10px;
    .detail {
      width: 250px;
      text-align: center;
    }
    .item_container {
      display: flex;
      .item {
        // flex: 1;
        width: 250px;
        text-align: center;
        border-right: 1px solid #eee;
        div:frist-child {
          color: #666;
        }
        div:last-child {
          font-weight: bold;
          margin-top: 10px;
        }
      }
    }

    .time {
      border: none;
    }
  }
  .yiyan {
    .yiyan_img {
      overflow: hidden;
      width: 280px;
      margin: 30px auto;
      img {
        width: 280px;
        float: left;
      }
    }
    .yiyan_text {
      text-align: center;
      font-size: 16px;
      color: #1890ff;
    }
  }
}
/deep/ .ant-col-17 {
  margin-left: 10px;
  padding: 20px;
}
/deep/ .ant-tabs-content {
  max-height: calc((100vh - 200px));
  overflow-y: scroll;
}
// /deep/ .ant-select-selection__placeholder {
//   display: block !important;
// }
.statusImg {
  height: 70px;
}
</style>
